﻿using MyMES.Error;
using Consul;
using MediatR;
using MyMES.Domain.zyy;
using MyMES.Infrastructure.Interface;
using MyMES.Read.API.Application.Command.Pressions;

namespace MyMES.Read.API.Application.Handler.Presssions
{
    public class PressionHandler : IRequestHandler<PressionCommand, APIResult<List<Pression>>>
    {
        public PressionHandler(IBaseRepository<Pression> pre)
        {
            Pre = pre;
        }

        public IBaseRepository<Pression> Pre { get; }

        /// <summary>
        /// 权限显示
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task<APIResult<List<Pression>>> Handle(PressionCommand request, CancellationToken cancellationToken)
        {
            try
            {
                APIResult<List<Pression>> result = new APIResult<List<Pression>>();
                result.Code = APIEnum.查询成功;
                result.Msg = "成功";

                string sql = "select *  from Pression where IsDlete=false";
                var list = await Pre.SelectAsync(sql);
                result.data = list;
                return result;
            }
            catch (Exception)
            {

                throw;
            }
           
        }
    }
}
